--
-- Author: shunguo.chen
-- Date: 2016-10-21 16:54:17
--
-- Payment 支付的状态

local fileName = string.getModeName(...)
local ClassRef = class(fileName)

-- payKey {
-- 		rechargeNum = 1;
-- 		monthCard = 2;
-- }

function ClassRef:read(value)
	self.payKey = value.payKey or "rechargeNum"
	self.value = value.value
	self.createdAt = value.createdAt
	self.expireAt = value.expireAt
end

function ClassRef:write(value)
	value.payKey = self.payKey
	value.value = self.value
	value.createdAt = self.createdAt
	value.expireAt = self.expireAt
end

function ClassRef:ctor()
	self.payKey = ""
	self.value = 0
	self.createdAt = 0
	self.expireAt = 0
end

function ClassRef:getRestDay()
	local dur = self.expireAt - app.session:getServerTime()
	if dur > 0 then
		return math.ceil(dur / 86400)
	else
		return 0
	end
end

return ClassRef